<commit_before>'use strict';

angular.module('lr.upload.directives').directive('uploadButton', function(upload) {
  return {
    restrict: 'EA',
    scope: {
      options: '=?uploadButton',
      multiple: '=?',
      forceIFrameUpload: '=?forceIframeUpload',
      url: '@',
      method: '@',
      onSuccess: '&',
      onError: '&',
      onComplete: '&'
    },
    link: function(scope, element) {

      var el = angular.element(element);
      var button = el.children()[0];

      el.css({
        position: 'relative',
        overflow: 'hidden',
        width: button.offsetWidth,
        height: button.offsetHeight,
        cursor: 'pointer'
      });

      var fileInput = angular.element('<input type="file" />');
      fileInput.on('change', function uploadButtonFileInputChange() {

        if (fileInput[0].files.length == 0) {
          return;
        }

        if (!scope.options) {
          scope.options = {};
        }

        var options = {
          url: scope.url || scope.options.url,
          method: scope.method || scope.options.method || 'POST',
          forceIFrameUpload: scope.forceIFrameUpload || scope.options.forceIFrameUpload || false,
          data: scope.options.data || {}
        };

        options.data[scope.options.paramName || 'file'] = fileInput;

        upload(options).then(
          function (response) {
            scope.onSuccess({response: response});
            scope.onComplete({response: response});
          },
          function (response) {
            scope.onError({response: response});
            scope.onComplete({response: response});
          }
        );
      });

      el.append(fileInput);

      if (upload.support.formData) {
        scope.$watch('multiple + forceIFrameUpload', function uploadButtonWatch(value) {
          fileInput.attr('multiple', !!(value && !scope.forceIFrameUpload));
        });
      }
    }
  };
});
<commit_msg>.files doesn't exist on < IE10 so we need to check for the property<commit_after>'use strict';

angular.module('lr.upload.directives').directive('uploadButton', function(upload) {
  return {
    restrict: 'EA',
    scope: {
      options: '=?uploadButton',
      multiple: '=?',
      forceIFrameUpload: '=?forceIframeUpload',
      url: '@',
      method: '@',
      onSuccess: '&',
      onError: '&',
      onComplete: '&'
    },
    link: function(scope, element) {

      var el = angular.element(element);
      var button = el.children()[0];

      el.css({
        position: 'relative',
        overflow: 'hidden',
        width: button.offsetWidth,
        height: button.offsetHeight,
        cursor: 'pointer'
      });

      var fileInput = angular.element('<input type="file" />');

      fileInput.on('change', function uploadButtonFileInputChange() {

        if (fileInput[0].files && fileInput[0].files.length === 0) {
          return;
        }

        if (!scope.options) {
          scope.options = {};
        }

        var options = {
          url: scope.url || scope.options.url,
          method: scope.method || scope.options.method || 'POST',
          forceIFrameUpload: scope.forceIFrameUpload || scope.options.forceIFrameUpload || false,
          data: scope.options.data || {}
        };

        options.data[scope.options.paramName || 'file'] = fileInput;

        upload(options).then(
          function (response) {
            scope.onSuccess({response: response});
            scope.onComplete({response: response});
          },
          function (response) {
            scope.onError({response: response});
            scope.onComplete({response: response});
          }
        );
      });

      el.append(fileInput);

      if (upload.support.formData) {
        scope.$watch('multiple + forceIFrameUpload', function uploadButtonWatch(value) {
          fileInput.attr('multiple', !!(value && !scope.forceIFrameUpload));
        });
      }
    }
  };
});

{'fraction_non_alphanumeric': 0.15167682926829268, 'fraction_numerical': 0.0022865853658536584, 'mean_word_length': 2.157177225340818, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, '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': '3285729', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1088, 'n_words': 199}