<commit_before>angular.module('zeroclipboard', [])
  .provider('uiZeroclipConfig', function() {
    // default configs
    var _zeroclipConfig = {
        buttonClass: '',
        swfPath: "ZeroClipboard.swf",
        trustedDomains: [window.location.host],
        cacheBust: true,
        forceHandCursor: false,
        zIndex: 999999999,
        debug: true,
        title: null,
        autoActivate: true,
        flashLoadTimeout: 30000,
        hoverClass: "zeroclipboard-is-hover",
        activeClass: "zeroclipboard-is-active"
    };
    this.setZcConf = function(zcConf) {
      angular.extend(_zeroclipConfig, zcConf);
    };
    this.$get = function() {
      return {
        zeroclipConfig: _zeroclipConfig
      };
    };
  })

  .directive('uiZeroclip', ['$document', '$window', 'uiZeroclipConfig',
      function($document, $window, uiZeroclipConfig) {

        var zeroclipConfig = uiZeroclipConfig.zeroclipConfig || {};
        var ZeroClipboard = $window.ZeroClipboard;

        return {
          scope: {
            onCopied: '&zeroclipCopied',
            onError: '&?zeroclipOnError',
            onBeforeCopy: '&?zeroclipOnBeforeCopy',
            client: '=?uiZeroclip',
            value: '=zeroclipModel',
            text: '@zeroclipText'
          },
          link: function(scope, element, attrs) {
            // config
            ZeroClipboard.config(zeroclipConfig);
            var btn = element[0];

            if (angular.isFunction(ZeroClipboard)) {
              scope.client = new ZeroClipboard(btn);
            }

            scope.$watch('value', function(v) {
              if (v === undefined) {
                return;
              }
              element.attr('data-clipboard-text', v);
            });

            scope.$watch('text', function(v) {
              element.attr('data-clipboard-text', v);
            });

            scope.client.on('aftercopy', _completeHnd = function(e) {
              scope.$apply(function() {
                scope.onCopied({$event: e});
              });
            });

            scope.client.on('error', function(e) {
              if (scope.onError) {
                scope.$apply(function() {
                  scope.onError({$event: e});
                });
              }
              ZeroClipboard.destroy();<commit_msg>fixed "_completeHnd is undefined" issue<commit_after>angular.module('zeroclipboard', [])
  .provider('uiZeroclipConfig', function() {
    // default configs
    var _zeroclipConfig = {
        buttonClass: '',
        swfPath: "ZeroClipboard.swf",
        trustedDomains: [window.location.host],
        cacheBust: true,
        forceHandCursor: false,
        zIndex: 999999999,
        debug: true,
        title: null,
        autoActivate: true,
        flashLoadTimeout: 30000,
        hoverClass: "zeroclipboard-is-hover",
        activeClass: "zeroclipboard-is-active"
    };
    this.setZcConf = function(zcConf) {
      angular.extend(_zeroclipConfig, zcConf);
    };
    this.$get = function() {
      return {
        zeroclipConfig: _zeroclipConfig
      };
    };
  })

  .directive('uiZeroclip', ['$document', '$window', 'uiZeroclipConfig',
      function($document, $window, uiZeroclipConfig) {

        var zeroclipConfig = uiZeroclipConfig.zeroclipConfig || {};
        var ZeroClipboard = $window.ZeroClipboard;

        return {
          scope: {
            onCopied: '&zeroclipCopied',
            onError: '&?zeroclipOnError',
            onBeforeCopy: '&?zeroclipOnBeforeCopy',
            client: '=?uiZeroclip',
            value: '=zeroclipModel',
            text: '@zeroclipText'
          },
          link: function(scope, element, attrs) {

            var btn = element[0];
            var _completeHnd;

            // config
            ZeroClipboard.config(zeroclipConfig);

            if (angular.isFunction(ZeroClipboard)) {
              scope.client = new ZeroClipboard(btn);
            }

            scope.$watch('value', function(v) {
              if (v === undefined) {
                return;
              }
              element.attr('data-clipboard-text', v);
            });

            scope.$watch('text', function(v) {
              element.attr('data-clipboard-text', v);
            });

            scope.client.on('aftercopy', _completeHnd = function(e) {
              scope.$apply(function() {
                scope.onCopied({$event: e});
              });
            });

            scope.client.on('error', function(e) {
              if (scope.onError) {
                scope.$apply(function() {
                  scope.onError({$event: e});
                });
              }
              ZeroClipboard.destroy();
{'fraction_non_alphanumeric': 0.1305732484076433, 'fraction_numerical': 0.006369426751592357, 'mean_word_length': 1.7246963562753037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '4796224', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1344, 'n_words': 217}