<commit_before>angular.module('angular.bootstrap.validator', [])
  .directive('abvIdentical', function() {
    return {
      restrict: 'A',
      scope: {
        targetModel: '=abvIdentical'
      },
      require: 'ngModel',
      link: function(scope, element, attributes, ngModel) {

        ngModel.$validators.abvIdentical = function(modelValue) {
          return modelValue == scope.targetModel;
        };

        scope.$watch("targetModel", function() {
          ngModel.$validate();
        });
      }

    };
  })
  .directive('abvDifferent', function() {
    return {
      restrict: 'A',
      scope: {
        targetModel: '=abvDifferent'
      },
      require: 'ngModel',
      link: function(scope, element, attributes, ngModel) {

        ngModel.$validators.abvDifferent = function(modelValue) {
          return modelValue != scope.targetModel;
        };

        scope.$watch("targetModel", function() {
          ngModel.$validate();
        });
      }

    };
  })
  .directive('abvForm', function($compile) {
    return {
      require: 'form',
      restrict: 'A',
      terminal: true,
      compile: function (tElement, tAttrs) {
        return (scope, element, attr, controller) => {
          var formName = controller.$name;
          var formNameSubmittedAnd = formName + '.$submitted && ';

          // disable submit buttons when the form is invalid after submit
          element.find('button[type="submit"]').attr("ng-disabled", formNameSubmittedAnd + formName + '.$invalid');

          // disable native form validation because the validation is handled by Angular
          element.attr('novalidate', 'novalidate');

          // for each form-control in a form group
          element.find('.form-group').each((index, formGroup) => {
            var controls = $(formGroup).find('.form-control');
            // Only input text areas should have feedback, textarea must not have feedback
            // only support one control per form-group as per Bootstrap CSS examples
            if (controls.length == 1) {
              // set the name. and ng-model appropriately
              var control = $(controls[0]);
              var controlName = control.attr('name');
              if (!controlName) {
                controlName = control.attr('id');
                control.attr('name', controlName);
              }
              if (!control.attr('ng-model') && !control.data('ng-model')) {
                control.attr('ng-model', controlName);
              }

              // add feedback icons
              if ($(formGroup).hasClass('has-feedback')) {
                control.after('<span class="glyphicon glyphicon-ok form-control-feedback" ng-if="' + formNameSubmittedAnd + formName + '.' + controlName + '.$valid' + '" aria-hidden="true"></span>');
                control.after('<span class="glyphicon glyphicon-remove form-control-feedback" ng-if="' + formNameSubmittedAnd + formName + '.' + controlName + '.$invalid' + '" aria-hidden="true"></span>');
              }

              $(formGroup).attr('ng-class', '{"has-error": ' + formNameSubmittedAnd + formName + '.' + controlName + '.$invalid }');
              // help blocks for error messages

              $(formGroup).find('.help-block[data-abv-error],.help-block[abv-error]').each((index, helpBlock) => {
                var errorField = $(helpBlock).data('abv-error') || $(helpBlock).attr('abv-error');
                $(helpBlock).attr('ng-show', formNameSubmittedAnd + formName + '.' + controlName + '.$error.' + errorField);
              });
            }
          });
          $compile(element.contents())(scope);
        };
      }
    };
  });<commit_msg>Used a directive for abv-error<commit_after>var NG_HIDE_CLASS = 'ng-hide';
var NG_HIDE_IN_PROGRESS_CLASS = 'ng-hide-animate';

angular.module('angular.bootstrap.validator', [])
  .directive('abvError', function($animate, $compile, $interpolate) {
    return {
      restrict: 'A',
      scope: {
        validatorName: '@abvError'
      },
      require: '^form',
      terminal: true,
      link: (scope, element, attrs, form) => {
        var controlName = element.siblings('.form-control')[0].name;
        var formName = '$parent.' + form.$name;
        var formNameSubmittedAnd = formName + '.$submitted && ';
        var watchExpr = formNameSubmittedAnd + formName + '.' + controlName + '.$error.' + scope.validatorName;
        scope.$watch(watchExpr, (value) => {
          $animate[value ? 'removeClass' : 'addClass'](element, NG_HIDE_CLASS, {
            tempClasses: NG_HIDE_IN_PROGRESS_CLASS
          });
        });
      }
    };
  })
  .directive('abvIdentical', function() {
    return {
      restrict: 'A',
      scope: {
        targetModel: '=abvIdentical'
      },
      require: 'ngModel',
      link: function(scope, element, attributes, ngModel) {

        ngModel.$validators.abvIdentical = function(modelValue) {
          return modelValue == scope.targetModel;
        };

        scope.$watch("targetModel", function() {
          ngModel.$validate();
        });
      }

    };
  })
  .directive('abvDifferent', function() {
    return {
      restrict: 'A',
      scope: {
        targetModel: '=abvDifferent'
      },
      require: 'ngModel',
      link: function(scope, element, attributes, ngModel) {

        ngModel.$validators.abvDifferent = function(modelValue) {
          return modelValue != scope.targetModel;
        };

        scope.$watch("targetModel", function() {
          ngModel.$validate();
        });
      }

    };
  })
  .directive('abvForm', function($compile) {
    return {
      require: 'form',
      restrict: 'A',
      terminal: true,
      compile: function(tElement, tAttrs) {
        return (scope, element, attr, controller) => {
          var formName = controller.$name;
          var formNameSubmittedAnd = formName + '.$submitted && ';

          // disable submit buttons when the form is invalid after submit
          element.find('button[type="submit"]').attr("ng-disabled", formNameSubmittedAnd + formName + '.$invalid');

          // disable native form validation because the validation is handled by Angular
          element.attr('novalidate', 'novalidate');

          // for each form-control in a form group
          element.find('.form-group').each((index, formGroup) => {
            var controls = $(formGroup).find('.form-control');
            // Only input text areas should have feedback, textarea must not have feedback
            // only support one control per form-group as per Bootstrap CSS examples
            if (controls.length == 1) {
              // set the name. and ng-model appropriately
              var control = $(controls[0]);
              var controlName = control.attr('name');
              if (!controlName) {
                controlName = control.attr('id');
                control.attr('name', controlName);
              }
              if (!control.attr('ng-model') && !control.data('ng-model')) {
                control.attr('ng-model', controlName);
              }

              // add feedback icons
              if ($(formGroup).hasClass('has-feedback')) {
                control.after('<span class="glyphicon glyphicon-ok form-control-feedback" ng-if="' + formNameSubmittedAnd + formName + '.' + controlName + '.$valid' + '" aria-hidden="true"></span>');
                control.after('<span class="glyphicon glyphicon-remove form-control-feedback" ng-if="' + formNameSubmittedAnd + formName + '.' + controlName + '.$invalid' + '" aria-hidden="true"></span>');
              }

              // set the has-error CSS if the form has been submitted
              $(formGroup).attr('ng-class', '{"has-error": ' + formNameSubmittedAnd + formName + '.' + controlName + '.$invalid }');
            }
          });
          $compile(element.contents())(scope);
        };
      }
    };
  });
{'fraction_non_alphanumeric': 0.14957049014653864, 'fraction_numerical': 0.0006316321374431531, 'mean_word_length': 2.1756919374247894, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 18, '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': '5806199', 'n_tokens_mistral': 2205, 'n_tokens_neox': 2124, 'n_words': 465}