<commit_before>/*global angular:true, browser:true*/

(function () {
  'use strict';

angular.module('mousetrap',[]).
factory('mousetrapHelper', ['$parse', function keypress($parse){

  function capitaliseFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
  } 

  return function(mode, scope, elm, attrs) {
    var params;
    params = scope.$eval(attrs['mousetrap'+capitaliseFirstLetter(mode)] || '{}');
    for (var binding in params) {
      (function(binding) {
        Mousetrap.bind(binding, function(e, combo){
          return scope.$apply(function() {
            $parse(params[binding])(e, combo);
          }); 
        }, mode);
      })(binding);
    }
  };<commit_msg>Add global bind plugin support<commit_after>/*global angular:true, browser:true*/

(function () {
  'use strict';

angular.module('mousetrap',[]).
factory('mousetrapHelper', ['$parse', function keypress($parse){

  function capitaliseFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
  }

  return function(mode, scope, elm, attrs) {
    var params;
    params = scope.$eval(attrs['mousetrap'+capitaliseFirstLetter(mode)] || '{}');

    for (var binding in params) {
      if(params.bindGlobal) {
        if(!angular.isFunction(Mousetrap.bindGlobal)) {
          throw new Error('[angular-mousetrap] Could not find Mousetrap Global Bind plugin, is it included?');
        }

        for (var globalBinding in params.bindGlobal) {
          (function(binding, params) {
            Mousetrap.bindGlobal(binding, function(e, combo){ return scope.$apply(params[binding](e, combo)); }, mode);
          })(globalBinding, params.bindGlobal);
        }
      }
      else {
        (function(binding, params) {
          Mousetrap.bind(binding, function(e, combo){ return scope.$apply(params[binding](e, combo)); }, mode);
        })(binding, params);
      }
    }
  };
{'fraction_non_alphanumeric': 0.16012558869701726, 'fraction_numerical': 0.0020931449502878076, 'mean_word_length': 3.3454545454545452, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4284835', 'n_tokens_mistral': 602, 'n_tokens_neox': 580, 'n_words': 117}